/*
 * @Author: jwb jwb@yoc.tech
 * @Date: 2022-05-18 11:16:30
 * @LastEditors: jwb jwb@yoc.tech
 * @LastEditTime: 2022-05-18 14:16:13
 * @FilePath: \mPaaS-uniapp-tutorial\vue.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const TransformPages = require("uni-read-pages");
const { webpack } = new TransformPages();
const path = require("path");

module.exports = {
  // 配置全局ROUTES变量结构
  configureWebpack: {
    plugins: [
      new webpack.DefinePlugin({
        ROUTES: webpack.DefinePlugin.runtimeValue(() => {
          const tfPages = new TransformPages({
            includes: ["path", "name", "aliasPath"],
          });
          return JSON.stringify(tfPages.routes);
        }, true),
      }),
    ],
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "src"),
      },
    },
  },
  devServer: {
    port: 9020, // 端口
    open: false, // 启动后打开浏览器
    overlay: {
      //  当出现编译器错误或警告时，在浏览器中显示全屏覆盖层
      warnings: true,
      errors: true,
    },
    proxy: {
      // 配置跨域
      "/api": {
        // target: 'http://testf.gw.yocyxc.com/ttbnapp',
        target: "https://boxdev-api.yocyxc.com/major/", // dev环境
        // target: 'https://boxtest-api.yocyxc.com/major/', // 测试H环境
        // target: 'https://api.pengdayx.com/major/', // 线上环境
        // target: 'https://jlstest-gw.yocyxc.com/ttbnapp/',
        // target: 'http://192.168.30.147:18084/major',  //虹良本地
        // target: 'http://192.168.30.132:18084/major', //经理本地
        // target: 'http://192.168.30.79:18084/major', // 建龙本地
        // target: 'http:// 192.168.30.96:18084/major', // 龙太平本地
        // ws:true,
        changOrigin: true,
        pathRewrite: {
          "^/api": "/",
        },
      },
      "/bury": {
        target: "https://boxdev-api.yocyxc.com/bury/", // dev环境
        // target: 'https://api.pengdayx.com/bury/', // 测试H环境
        changOrigin: true,
        pathRewrite: {
          "^/bury": "/",
        },
      },
    },
  },
};
